@extends('layouts.app')
@section('content')
<section class="content-header">
    <h1>
        登山
        <small>奖品列表</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/dashboard"><i class="fa fa-dashboard"></i>家</a></li>
        <li><a href="#">登山</a></li>
        <li class="active">奖品列表</li>
    </ol>

</section>

<section class="content-header">

@if (Session::has('mgssages'))
<div class="alert alert-success alert-dismissible">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
    <h4><i class="icon fa fa-check"></i> 状态!</h4>
    <ul>
        @foreach (Session::get('mgssages') as $message)
        <li>{{ $message }}</li>
        @endforeach 
    </ul>
</div>
@endif
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">奖品列表</h3>
                    <div class="box-tools">
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                        <div class="row">
                            <div class="col-sm-6"></div>
                            <div class="col-sm-6"></div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <table id="example2" class="table table-bordered table-hover dataTable"
                                       role="grid" aria-describedby="example2_info">
                                    <thead>
                                    <tr role="row">
                                        <th>编号
                                        </th>
                                        <th>
                                            奖品名称
                                        </th>
                                        <th>
                                            奖品数量
                                        </th>
                                        <th>
                                            中奖数量
                                        </th>
                                        <th>
                                            中奖概率
                                        </th>
                                        <th>
                                            操作
                                        </th>
                                    </tr>
                                    </thead>
                                    <?php $i=1;?>
                                    <tbody>
                                        @if(count($list)>0)@foreach($list as $val)
                                        <tr role="row" class="even">
                                            <td class="sorting_1">{{$i++}}</td>
                                            <td>{{$val->awardTitle}}</td>
                                            <td>{{$val->awardNum}}</td>
                                            <td>{{$val->awardWinNum}}</td>
                                            <td>{{$val->awardProbability}}</td>
                                            <td style="text-align: center">
                                                <a class="btn btn-primary  btn-lg active btn-sm" href="/admin/hillclimb/edit/{{$val->id}}">编辑</a>
                                                <a class="btn btn-primary  btn-lg active btn-sm" href="/admin/hillclimb/winlist?id={{$val->id}}">中奖列表</a>
                                            </td>
                                        </tr>
                                        @endforeach @endif

                                    </tbody>
                                    <tfoot>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                        @include("layouts.page",['paginator'=>$list])

                    </div>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</section>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">警告</h4>
            </div>
            <div class="modal-body">
                你确定要下线么？
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <a  class="btn btn-primary active btn-sm model_delete" data-val="" role="button">确定</a>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="releaseModal" tabindex="-1" role="dialog" aria-labelledby="releaseModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="releaseModalLabel">警告</h4>
            </div>
            <div class="modal-body">
                你确定要发布么？
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <a  class="btn btn-primary active btn-sm" data-val="" role="button">确定</a>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="qrcodeModal" tabindex="-1" role="dialog" aria-labelledby="qrcodeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="qrcodeModalLabel">活动链接</h4>
            </div>
            <div class="modal-body" style="display: inline-block; width: 100%;">
                <div style="display: inline-block;text-align: center;border-right: 1px solid #ddd;float: left;" class="col-md-5">
                    <img src="" id="QrCode-img">
                    <div>微信扫一扫</div>
                </div>
                <div class="form-horizontal col-md-7" style="display: inline-block;float: left;">
                    <div class="col-md-12 single">
                        <div class="form-group">
                            <div class="col-sm-12">
                                链接地址
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="text" class="form-control" name="active-link" id="active-link" value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <a  class="btn btn-primary active btn-sm btn-copy" role="button">复制</a>
                            </div>
                        </div>
                    </div>
                </div>
                
            </div>
            
        </div>
    </div>
</div>
<style>
    a{cursor: pointer;}
    .panel{ margin-left: 15px; margin-right: 15px;}
</style>

<script>
$(function(){
    $(".reset").click(function(){
        $(".form-control").val("");
    });
    $(".btn-href").click(function(){
        $("#active-link").val($(this).data("url"));
        $("#QrCode-img").attr('src',$(this).data("qcode"));
    });
    $(".btn-delete").click(function(){
         $("#myModal").find('.modal-footer .btn-primary').attr('href', "/admin/active/del/" + $(this).data("val"));
    });
    $(".btn-release").click(function(){
         $("#releaseModal").find('.modal-footer .btn-primary').attr('href', "/admin/active/release/" + $(this).data("val"));
    });
    $(".btn-copy").on('click',function(){
        var e=document.getElementById("active-link");//对象是content
        e.select(); //选择对象
        document.execCommand("Copy"); //执行浏览器复制命令
        alert("复制成功");
    });
});
if($(".alert").css("display","block")){
        setTimeout(function(){
            $(".alert").alert('close');
        }, 3000);
}
var search = location.search.substring(1);
if (search) {
    try {
        var query = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');

        $.each(query, function(k, v) {
            $('[name=' + k + ']').val(v);
        });
    } catch (e) {
        console.log(e);
    }

}
        
        
</script>
@endsection